package com.fowo.api.service.handleWork;

import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.fowo.api.entity.ListingFather;
import com.fowo.api.mapper.ListingFatherMapper;
import com.fowo.api.model.listing.father.ListingFatherBatchRelievePairAction;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

public class ListingFatherBatchRelievePair implements ListingFatherBatchRelievePairAction {
    @Resource
    private ListingFatherMapper listingFatherMapper;

    @Override
    public void run(List<Long> idList) throws Exception {
        for(Long id : idList){
            new LambdaUpdateChainWrapper<>(listingFatherMapper)
                    .set(ListingFather::getPairProduct, null)
                    .set(ListingFather::getProductName, "")
                    .set(ListingFather::getSku, "")
                    .set(ListingFather::getClassify, null)
                    .set(ListingFather::getBrand, null)
                    .set(ListingFather::getPairStatus, false)
                    .set(ListingFather::getPairUpdateTime, new Date())
                    .set(ListingFather::getPairType, "")
                    .eq(ListingFather::getId, id)
                    .update();
        }
    }
}
